using Microsoft.AspNetCore.Mvc;
using MediatR;
using RBAC.ErrorCode;
using RBAC.Write.Api.Application.Command.ProcessManagements;

namespace RBAC.Write.Api.Controllers.ProcessManagements
{
    /// <summary>
    /// 工艺流程管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessFlowController : ControllerBase
    {
        private readonly IMediator _mediator;
        public ProcessFlowController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 新增工艺流程（主表+明细+附件）
        /// </summary>
        [HttpPost]
        public async Task<APIResult<int>> AddProcessFlow([FromBody] AddProcessFlowCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 编辑工艺流程（主表+明细+附件全量覆盖）
        /// </summary>
        [HttpPost]
        public async Task<APIResult<int>> UpdateProcessFlow([FromBody] UpdateProcessFlowCommand command)
        {
            return await _mediator.Send(command);
        }

        /// <summary>
        /// 批量删除工艺流程（逻辑删除）
        /// </summary>
        [HttpPost]
        public async Task<APIResult<int>> BatchDeleteProcessFlows([FromBody] BatchDeleteProcessFlowsCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
